﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using ERF.Input;

namespace ERF
{
    /// <summary>
    /// this is the abstract state class from which all states should inherit.
    /// </summary>
    public abstract class State
    {
        #region fields
        /// <summary>
        /// The machine that this state is attached to.
        /// </summary>
        protected StateMachine machine;
        protected IInputHandler input;

        protected bool initialized;
        #endregion

        /// <summary>
        /// if this boolean is set to false, the machine will call the initialize method when the state is activated.
        /// </summary>
        public bool Initialized
        {
            get { return initialized; }
        }

        /// <summary>
        /// Creates a new instance of State.
        /// </summary>
        /// <param name="machine">The machien that the state belongs to.</param>
        protected State(StateMachine machine)
        {
            this.machine = machine;
            this.input = machine.CurrentGame.Input;
        }

        /// <summary>
        /// This method will be called when a state should be destroyed, meaning that it should be initialized the next
        /// time it is called.
        /// </summary>
        public virtual void Destroy()
        {
            initialized = false;
        }

        /// <summary>
        /// This method will be called when the state is marked as not initialized. Write the code that makes the state ready
        /// here.
        /// </summary>
        public virtual void Initialize()
        {
            initialized = true;
        }
        /// <summary>
        /// This method is called each time the loop goes through.
        /// </summary>
        /// <param name="gameTime"></param>
        public abstract void Update(GameTime gameTime);

        /// <summary>
        /// This method is called when the state machine switches back to this state, and if the state's initialize method was not called.
        /// </summary>
        public virtual void Continue()
        {

        }

    }
}
